package org.keyuan.service.impl;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;

import org.keyuan.dao.EmployeeDao;
import org.keyuan.entity.Employee;
import org.keyuan.service.EmployeeService;
import org.keyuan.util.PageUtil;

public class EmployeeServiceImpl extends ServiceSupport<Employee> implements EmployeeService{
	private EmployeeDao employeeDao;
	public void setEmployeeDao(EmployeeDao employeeDao) {
		this.employeeDao = employeeDao;
		this.dao=this.employeeDao;
	}
	@Override
	public Employee login(Employee employee) {
		
		PageUtil<Employee> pageUtil=new PageUtil<Employee>();
		pageUtil.setFristIndex(-1);
		pageUtil.setPageSize(-1);
		LinkedHashMap<String, String> paramNames=new LinkedHashMap<String, String>();
		LinkedList<Object> paramValues=new LinkedList<Object>();
		paramNames.put("username", "and");
		paramValues.add(employee.getUsername());
		paramNames.put("password","and");
		paramValues.add(employee.getPassword());
		pageUtil.setParamNames(paramNames);
		pageUtil.setParamValues(paramValues);
		List<Employee> emps=this.getPagingdata(Employee.class, pageUtil);
		if(emps!=null && emps.size()>0){
			return emps.get(0);
		}
		return null;
	}
	@Override
	public void updateEmpPurview(Employee emp) {
		this.employeeDao.updateEmpPurviewGroupDao(emp);
	}
}
